package HP.filetest;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.*;
public class File {

        public  void readAndRead() {
            try
            {
                FileReader fr = new FileReader("D:\\need.txt");//需要读取的文件路径
                BufferedReader br = new BufferedReader(fr);
                String s = br.readLine();
                while(s!=null)//如果当前行不为空
                {
                    System.out.println(s);//打印当前行
                    s= br.readLine();//读取下一行
                }
                br.close();//关闭BufferReader流
                fr.close();		//关闭文件流
            }catch(IOException e)//捕捉异常
            {
                System.out.println("指定文件不存在");//处理异常
            }
        }
    public static boolean writefile(String path,String content){
        try{
            OutputStream out = new FileOutputStream(path);
            out.write(content.getBytes());
            out.close();
            return true;
        }catch(Exception e){
            e.printStackTrace();
            return false;
        }
    }

    public static void main(String [] args)
    {
        File start = new File();
        //start.readAndRead();
        writefile("D:\\Dos-Mini-Bank\\123456789.card","qqqqqqqqqqqqq");
    }

}
